package cn.autumnorange.controller;

import cn.autumnorange.dto.*;
import cn.autumnorange.vo.ResultVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

/**
 * @InterfaceName OrderController
 * @Description
 * @Date 2019/4/11 15:38
 * @Version 1.0
 */
@RequestMapping("/order")
@Transactional(rollbackFor = Exception.class, readOnly = false, propagation = Propagation.REQUIRED)
public interface OrderController {

    /**
     * 创建订单
     *
     * @Param [createOrderDTO]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PostMapping("/create")
    ResultVO createOrder(CreateOrderDTO createOrderDTO);

    /**
     * 编辑订单
     *
     * @Param [editOrderDTO]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @PostMapping("/edit")
    ResultVO editOrder(EditOrderDTO editOrderDTO);

    /**
     * 删除订单
     *
     * @Param [orderId]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/del")
    ResultVO deleteOrder(String orderId);

    /**
     * 订单审核
     *
     * @Param [orderId, orderStatus]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/audit")
    ResultVO auditOrder(String orderId, int orderStatus);

    /**
     * 订单发货
     *
     * @Param [orderId, deliveryStatus]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/deliver")
    ResultVO deliverGoods(String orderId, int deliveryStatus);

    /**
     * 填写快递单号
     *
     * @Param [orderId, courierNumber]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/courierNumber")
    ResultVO courierNumber(String orderId, String courierNumber);

    /**
     * 订单详情
     *
     * @Param [orderId]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/orderdetail")
    ResultVO orderdetail(String orderId);

    /**
     * 订单列表
     *
     * @Param [page, size]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/orderList")
    ResultVO orderList(Integer page, Integer size);

    /**
     * 搜索订单
     *
     * @Param [buyerPhone, page, size]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/findOrder")
    ResultVO findOrder(String buyerPhone, Integer page, Integer size);

    /**
     * 审核订单列表
     *
     * @Param [orderStatus, page, size]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/auditOrderList")
    ResultVO auditOrderList(int orderStatus, Integer page, Integer size);

    /**
     * 订单发货列表
     *
     * @Param [deliveryStatus, page, size]
     * @return cn.autumnorange.vo.ResultVO
     */
    @PreAuthorize("hasRole('ROLE_admin')")
    @GetMapping("/deliveryOrderList")
    ResultVO deliveryOrderList(int deliveryStatus, int orderStatus, Integer page, Integer size);
}
